<extend name="Public/base"/>

<block name="body">
	<style>
	.my-item{float:left; margin-right:5px;} .form-horizontal .item-label{display:inline;}
	.record-item{margin-bottom:10px;}
	.kebiao-container{margin-bottom:10px;}
	.kebiao-container h3{border-bottom:2px solid #4cdb00; padding:0 0 5px 0; margin-bottom:10px;}
	.my-select{height:30px; width:160px;}
	</style>
    <div class="main-title">
        <h2>修改课表</h2>
    </div>
    <form action="{:U('doUpdate')}" method="post" class="form-horizontal">
        <div class="form-item my-item">
            <label class="item-label">所属学校</label>
            <div class="controls">
               <select name="school_id">
               	<option value="0">请选择</option>
               	<volist name="schoolList" id="vo">
                    <option value="{$vo.id}" <if condition="$info['school_id'] eq $vo['id']">selected="selected"</if> >{$vo.title}</option>
                </volist>
               </select>
            </div>   
        </div>
        <div class="form-item my-item">
            <label class="item-label">所属系</label>
            <div class="controls">
               <select name="xi_id">
               	<option value="0">请选择</option>
               	<volist name="xiList" id="vo">
                    <option value="{$vo.id}" <if condition="$info['xi_id'] eq $vo['id']">selected="selected"</if> >{$vo.title}</option>
                </volist>
               </select>
            </div>   
        </div>
        <div class="form-item my-item">
            <label class="item-label">所属年级</label>
            <div class="controls">
               <select name="nianji_id">
               	<option value="0">请选择</option>
               	<volist name="nianjiList" id="vo">
                    <option value="{$vo.id}" <if condition="$info['nianji_id'] eq $vo['id']">selected="selected"</if> >{$vo.title}</option>
                </volist>
               </select>
            </div>   
        </div>
        <div class="form-item my-item">
            <label class="item-label">所属班级</label>
            <div class="controls">
               <select name="banji_id">
               	<option value="0">请选择</option>
               	<volist name="banjiList" id="vo">
                    <option value="{$vo.id}" <if condition="$info['banji_id'] eq $vo['id']">selected="selected"</if> >{$vo.title}</option>
                </volist>
               </select>
            </div>   
        </div>
        <div class="form-item my-item">
            <label class="item-label">星期</label>
            <div class="controls">
               <select name="week_id">
               	<option value="0">请选择</option>
               	<volist name="weekList" key='k' id="vo">
                    <option value="{$k}" <if condition="$info['week_id'] eq $k">selected="selected"</if> >{$vo}</option>
                </volist>
               </select>
            </div>   
        </div>
        <div style="clear:both;"></div>
        
        <div class="kebiao-container">
        	<h3>课表记录</h3>
        	
        	<for start='1' end='9'>
        		<php>$fId = ($i - 1) * 2 + 1;</php>
        		<assign name="fid" value="$fId" />
        		<div class="record-item">
					<label class="item-label">第{$i}节课</label>
					<select name="start_time_id[]" class="my-select time-select" id="time-select-{$fid}">
						<option value="0">请选择课程开始时间</option>
						<volist name="timeList" key='k' id="vo">
	                        <option value="{$k}" id="select-{$fid}-option-{$k}" <if condition="$content[$i - 1]['start_time_id'] eq $k">selected="selected"</if> >{$vo}</option>
	                    </volist>
					</select>
					<select name="end_time_id[]" class="my-select time-select" id="time-select-{$fid + 1}">
						<option value="0">请选择课程结束时间</option>
						<volist name="timeList" key='k' id="vo">
	                        <option value="{$k}" id="select-{$fid + 1}-option-{$k}" <if condition="$content[$i - 1]['end_time_id'] eq $k">selected="selected"</if>>{$vo}</option>
	                    </volist>
					</select>
					<input type="text" class="text input-middle" name="title[]" value="{$content[$i - 1]['title']}" placeholder="课程名称" />
				</div>
        	</for>
        </div>
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
    	$(function(){
   			var timeList = {$timeListJson};
    		$('.time-select').change(function(e){
    			var clickedId = e.currentTarget.id;
    			var arr = clickedId.split('-');
    			var id = arr[arr.length-1];
    			var nextId = 'time-select-' + (parseInt(id) + 1);
    			var size = $('#' + nextId).size();
    			if (size == 1){
    				var val = e.currentTarget.value;
    				for(var i = 1; i <= val; i ++){
    					$('#select-' + (parseInt(id) + 1) + '-option-' + i).remove();
    				}
    			}
    		});
    	});
    	//console.log(Object.keys(timeList).length);
    	
    	
        //导航高亮
        highlight_subnav('{:U('Teacher/index')}');
    </script>
</block>
